﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using SignalR;
using SignalR.Hubs;
using WP7SignalRHelperServer;

namespace SignalRHubs
{
    public class ObjectHub : Hub
    {
        // List of connected Phone clients on server .. feel free to persist or use this list however.
        private static List<PhoneClient> PhoneClientList = new List<PhoneClient>();

        // SignalR method call to add a new Phone client connection & join object sync.
        public void JoinFromPhone(string phoneID)
        {
            PhoneClient phoneClientToAdd = new PhoneClient();
            phoneClientToAdd.PhoneClientId = phoneID;
            PhoneClientList.Add(phoneClientToAdd);
            this.Caller.addClients(PhoneClientList.ToArray());
        }

        // Sync custom object
        public void PushObjectToClients(CustomClass customObject)
        {
            Clients.pushObject(customObject);
        }
    }
}